perm filename STRING.POX[POX,WD] blob sn#410390 filedate 1979-01-07 generic text, type C, neo UTF8
COMMENT ⊗   VALID 00002 PAGES
C REC  PAGE   DESCRIPTION
C00001 00001
C00002 00002	\|\\				Define Brick Character
C00011 ENDMK
C⊗;
\|\\;				Define Brick Character
\;
\⊂'000040;\;	VERREM - REM's syntax for defining macros with args 
\;
\8LENGTH(STRING)[\N		length of string
\	;\Q0\N				save reg 0
\	;\oSP{0 }\N			put a space in an overlay
\	;\7SP;\N			width of space to ac
\	;\∂←SP;\N			expunge overlay
\	;\→0\N				store ac in reg 0
\	;\oSTR{0 ⊗STRING⊗}\N		put string in overlay
\	;\7STR;\N			width of string to ac
\	;\∂←STR;\N			expunge overlay
\	;\-0\N				subtract off width of space
\	;\/0\N				divide by width of space
\	;\q0]\;				restore reg 0
\;
\;\8NULL(STRING)[\N		is the string null
\;\	;\oSTR{0⊗STRING⊗}\N		put string in overlay
\;\	;\3STR;\N			height of overlay to ac
\;\	;\∂←STR;\N			expunge overlay
\;\	;\+'200000;\N			add 200000 to ac
\;\	;\!COMPAC;]\;			complement ac
\;
\8NULL(STRING)[\!COMPAC(\!LENGTH(⊗STRING⊗););]\N
\;
\8FIRST(STRING)[\N		first character of a string
\	;\P\N				save ac
\	;\!OMIT(\a⊗STRING⊗);\N	ascii of 1st char to ac
\	;\N				and flush rest of string
\	;\A∀\N				make char from ac
\	;\p]\;				restore ac
\;
\8REST(STRING)[\N		rest of a string
\	;\P\N				save ac
\	;\a⊗STRING⊗\N			carve off 1st char
\	;\p]\;				restore ac
\;
\8ISSPACE(CHR)[\N		is char a space
\	;\a⊗CHR⊗\N			ascii of char to ac
\	;\-=32;\N			sub ascii of space
\	;\!ISACZERO;]\;			is ac zero
\8ISCRLF(CHAR)[\N		is char a cr or lf
\	;\a⊗CHAR⊗\N			ascii of char to ac
\	;\P\N				push ac
\	;\-=13;\N			sub ascii of cr from ac
\	;\!COMPAC(\!ISACZERO;);\N	was it a cr
\	;\?EVAL((\p\N				get back ascii of char
\		;\-=10;\N			sub ascii of lf
\		;\!COMPAC(\!ISACZERO;);));\N	was it a lf
\	;\!COMPAC;]\;			restore pos logic
\;
\;
\8ROTL(STRING)[\N		rotate a string left
\	;\P\N				save ac
\	;\a⊗STRING⊗\N			ascii of 1st char to ac
\	;\A∀\N				make char from ac
\	;\p]\;				restore ac
\;
\8STRINGCOM(X,Y)[\N		compare two strings
\	;\!COMPAC(\!NULL(⊗X⊗);\N	if null(x) nand null(y)
\		 ;\?NULL(⊗Y⊗););\N
\	;\?STRINGCOM1(⊗X⊗,⊗Y⊗);\N	call stringcom1
\	;\!COMPAC;]\;			otherwise return true
\;
\8STRINGCOM1(X,Y)[\N		comp strings not both null
\	;\!COMPAC(\!NULL(⊗X⊗););\N	if x is not null
\	;\?COMPAC((\!NULL(⊗Y⊗);));\N	and y is not null
\	;\?STRINGCOM2(⊗X⊗,⊗Y⊗);\N	call stringcom2 and
\	;\!COMPAC;]\N			output in negative logic
\;
\8STRINGCOM2(X,Y)[\N		compare non-null strings
\	;\Q0\N				save reg 0
\	;\!OMIT(\a⊗X⊗);\N		first char of x to ac
\	;\→0\N				store in reg 0
\	;\!OMIT(\a⊗Y⊗);\N		first char of y to ac
\	;\-0\N				compare with first char of x
\	;\!COMPAC;\N			if they're equal
\	;\?STRINGCOM(\!REST(⊗X⊗);,\!REST(⊗Y⊗););\N
\	;\N				compare rest of strings
\	;\q0]\;				restore reg 0
\;
\8MAPFIRST(MAC,STR)[\N		apply macro to each char of string
\	;\P\N				save ac
\	;\!COMPAC(\!NULL(⊗STR⊗););\N	if string is not null
\	;\?⊗MAC⊗(\?FIRST(⊗STR⊗););\N
\	;\N				apply macro to first char
\	;\?MAPFIRST(⊗MAC⊗,\?REST(⊗STR⊗););\N
\	;\N				apply macro to rest of string
\	;\p]\;				restore ac
\;
\8MAPREST(MAC,STR)[\N		apply macro to each tail of string
\	;\P\N				save ac
\	;\!COMPAC(\!NULL(⊗STR⊗););\N	if string is not null
\	;\?⊗MAC⊗(⊗STR⊗);\N
\	;\N				apply macro to string
\	;\?MAPREST(⊗MAC⊗,\?REST(⊗STR⊗););\N
\	;\N				apply macro to rest of string
\	;\p]\;				restore ac
\;
\8CAPCHAR(CHAR)[\N		make char capital
\	;\P\Q0\N			save ac and reg 0
\	;\a⊗CHAR⊗\N			ascii of char to ac
\	;\→0\N				store ac in reg 0
\	;\-'140;\N			subtract octal 140 from ac
\	;\?EVAL((\N			if ac exceeds 100 octal
\		;\←0\N				load ac from reg 0
\		;\¬'173;\N			sub ac from octal 173
\		;\?CAPCHAR1(⊗CHAR⊗);));\N	if ac less than 173
\	       ;\N				do the capitalization
\	;\!COMPAC;\N			complement ac
\	;\?EVAL(⊗CHAR⊗);\N		pass char unchanged
\	;\q0\p]\;			restore reg 0 and ac
\;
\8CAPCHAR1(CHAR)[\N		sub octal 40 from 1st char of CHAR
\	;\P\N				save ac
\	;\a⊗CHAR⊗\N			ascii of char to ac
\	;\-'40;\N			sub octal 40 from ac
\	;\A∀\N				generate capital letter
\	;\!REST(⊗CHAR⊗);\N		pass rest of CHAR
\	;\p]\;				restore ac
\;
\8CAPFIRST(STRING)[\N		capitalize first char of string
\	;\P\N				save ac
\	;\!COMPAC(\!NULL(⊗STRING⊗););\N	if string is not null
\	;\?CAPCHAR(\?FIRST(⊗STRING⊗););\N
\	;\N				capitalize first char
\	;\?REST(⊗STRING⊗);\N		pass rest of string
\	;\p]\;				restore ac
\;
\8CAPALL(STRING)[\N		capitalize all of string
\	;\!MAPFIRST(CAPCHAR,⊗STRING⊗);]\;
\;
\8TITCAPS(STR)[\N		cap chars after spaces
\	;\P\N				save ac
\	;\!COMPAC(\!NULL(⊗STR⊗););\N	if string is not null
\	;\?TITCAPS2(⊗STR⊗);\N
\	;\p]\;				restore ac
\;
\8TITCAPS1(STR)[\N		cap chars after spaces
\	;\P\N				save ac
\	;\!COMPAC(\!NULL(⊗STR⊗););\N	if string is not null
\	;\?TITCAPS3(⊗STR⊗);\N
\	;\p]\;				restore ac
\;
\8TITCAPS2(STR)[\N
\	;\!CAPCHAR(\!FIRST(⊗STR⊗););\N	cap first char
\	;\!TITCAPS4(⊗STR⊗);]\;
\;
\8TITCAPS3(STR)[\N
\	;\!FIRST(⊗STR⊗);\N
\	;\!TITCAPS4(⊗STR⊗);]\;
\;
\8TITCAPS4(STR)[\N
\	;\P\N				save ac
\	;\!ISSPACE(\!FIRST(⊗STR⊗););\N
\	;\?TITCAPS((\!REST(⊗STR⊗);));\N
\	;\!COMPAC;\N
\	;\?TITCAPS1((\!REST(⊗STR⊗);));\N
\	;\p]\;				restore ac
\;
\8UNDERLINE(STR)[\!MAPFIRST(UNDERLINECHAR,⊗STR⊗);]\;
\;
\8UNDERLINECHAR(CHAR)[\N	underline non crlf chars
\	;\P\N				save ac
\	;\!COMPAC(\!ISCRLF(⊗CHAR⊗););\N	if not cr or lf
\	;\?UNDERLINECHAR1(⊗CHAR⊗);\N	underline it
\	;\!COMPAC;\N			complement ac
\	;\?EVAL(⊗CHAR⊗);\N		pass bare char
\	;\p]\;				restore ac
\;
\8UNDERLINECHAR1(CHAR)[\[=2;=2;⊗CHAR⊗\]]\;
\;